<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="panel-heading">
        <ul class="nav nav-tabs">
            <li class="active"><a data-toggle="tab" href="#base">{:__('Goods_info')}</a></li>
            <li><a data-toggle="tab" href="#attrs">{:__('Specification_add')}</a></li>
        </ul>
    </div>
    <div class="tab-content">
        <!--基本信息-->
        <div class="active tab-pane" id="base">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('Category_id1')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-category_id" data-rule="required" data-source="goods_category/selectpage" data-params='{"custom[type]":"goods","custom[pid]":"0"}' class="form-control selectpage" name="row[category_id]" type="text" value="{$row.category_id|htmlentities}">
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('Category_id2')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-category2_id" data-rule="required" data-source="goods_category/selectpage" data-params='{"custom[type]":"goods"}' class="form-control selectpage" name="row[category2_id]" type="text" value="{$row.category2_id|htmlentities}">
                </div>
            </div>
            <!--            <div class="form-group">-->
            <!--                <label class="control-label col-xs-12 col-sm-2">{:__('Brand_id')}:</label>-->
            <!--                <div class="col-xs-12 col-sm-8">-->
            <!--                    <input id="c-brand_id" data-rule="required" data-source="brand/index" class="form-control selectpage" name="row[brand_id]" type="text" value="{$row.brand_id|htmlentities}">-->
            <!--                </div>-->
            <!--            </div>-->
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('Goods_name')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-goods_name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('已售数量')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-sold_number" data-rule="required" class="form-control" name="row[sold_number]" type="text" value="{$row.sold_number|htmlentities}" value="0" step="1" min="0" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')">
                </div>
            </div>


            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('Thumbnail_image')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <div class="input-group">
                        <input id="c-thumbnail_image" data-rule="required" class="form-control" size="50" name="row[thumbnail_image]" type="text" value="{$row.thumbnail_image|htmlentities}">
                        <div class="input-group-addon no-border no-padding">
                            <span><button type="button" id="plupload-thumbnail_image" class="btn btn-danger plupload" data-input-id="c-thumbnail_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-thumbnail_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                            <span><button type="button" id="fachoose-thumbnail_image" class="btn btn-primary fachoose" data-input-id="c-thumbnail_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                        </div>
                        <span class="msg-box n-right" for="c-thumbnail_image"></span>
                    </div>
                    <ul class="row list-inline plupload-preview" id="p-thumbnail_image"></ul>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('Goods_images')}(图片尺寸：750*750):</label>
                <div class="col-xs-12 col-sm-8">
                    <div class="input-group">
                        <input id="c-goods_images" data-rule="required" class="form-control" size="50" name="row[goods_images]" type="text" value="{$row.goods_images|htmlentities}">
                        <div class="input-group-addon no-border no-padding">
                            <span><button type="button" id="plupload-goods_images" class="btn btn-danger plupload" data-input-id="c-goods_images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-goods_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                            <span><button type="button" id="fachoose-goods_images" class="btn btn-primary fachoose" data-input-id="c-goods_images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                        </div>
                        <span class="msg-box n-right" for="c-goods_images"></span>
                    </div>
                    <ul class="row list-inline plupload-preview" id="p-goods_images"></ul>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <div class="radio">
                        {foreach name="statusList" item="vo"}
                        <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
                        {/foreach}
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">{:__('运费')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <div class="radio">
                        {foreach name="isShipList" item="vo"}
                        <label for="row[is_ship]-{$key}" class="">
                            <input id="row[is_ship]-{$key}" name="row[is_ship]" type="radio" class="select-radio type_type" value="{$key}" {in name="key" value="$row.is_ship"}checked{/in} /> {$vo}
                        </label>
                        {/foreach}
                    </div>
                </div>
            </div>
            <div class="form-group is_ship"  <?php if($row['is_ship']==0){echo 'style="display: none"';}?> >
                <label class="control-label col-xs-12 col-sm-2">{:__('运费类型')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <div class="radio">
                        {foreach name="freightTypeList" item="vo"}
                        <label for="row[freight_type]-{$key}">
                            <input id="row[freight_type]-{$key}" name="row[freight_type]" type="radio" class="select-radio" value="{$key}" {in name="key" value="$row.freight_type"}checked{/in} /> {$vo}
                        </label>
                        {/foreach}
                    </div>
                </div>
            </div>
            <div class="form-group is_ship"  <?php if($row['is_ship']==0){echo 'style="display: none"';}?>>
                <label class="control-label col-xs-12 col-sm-2">{:__('运费模版')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-freight_id"  data-source="logistics/index" class="form-control selectpage" name="row[freight_id]" type="text" value="{$row.freight_id}">
                </div>
            </div>
        </div>


        <!--规格/参数-->
        <div class="tab-pane" id="attrs">
            <style>
                .attr-table input {
                    padding: 0;
                    text-align: center;
                }
                .attr-table thead th {
                    text-align: center;
                }
                .attr-table tbody tr td {
                    text-align: center;
                    vertical-align: middle!important;
                }
                .attr-table .disabled td, .attr-table .disabled td input {
                    background: #F7F7F7;
                    color: #b1b1b1;
                }
                .attr-table .sku-img {
                    width: 40px; height: 40px;
                    cursor: pointer;
                    color: #b1b1b1;
                    display: inline-block;
                    border: 1px solid #ddd;
                }
                .attr-table .sku-img img {
                    width: 40px; height: 40px;
                }
            </style>
            <script>
                var skus = []
                skus = {$skus_json};
                var attrItems = []
                attrItems = {$attrItems_json};
            </script>
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-2">库存/规格</label>
                <div class="col-xs-12 col-sm-8" id="app" v-cloak>
                    <div style="margin-bottom: 5px;">
                        <input type="text" class="form-control" style="width: 100px" @keyup.enter="addRow" ref="attr-group-name" placeholder="输入规格名称">
                        <a class="btn btn-sm btn-primary" id="btn-add-group" @click="addRow">添加规格</a>
                    </div>
                    <div>
                        <div class="panel panel-default" v-for="(item, i) in attrGroups" :key="i">
                            <header class="panel-heading">
                                <span class="pointer color-disabled" @click="removeGroup(i)">X</span>
                                <span>{{item}}</span>
                            </header>
                            <div class="row" style="margin: 5px 0;">
                                <div class="col-md-6 col-sm-6 col-xs-6">
                                    <div class="input-group">
                                        <input type="text" class="form-control" @keyup.enter="addChild(i)" :ref="'attr-item-name-' + i">
                                        <span class="input-group-addon pointer" @click="addChild(i)">添加</span>
                                    </div>
                                </div>
                                <div class="col-md-6 col-sm-6 col-xs-6" style="padding: 5px 0;">
                                    <span class="tag pointer" title="移除" v-for="(v, j) in attrItems[i]" :key="j" @click="removeChild(i, j)">{{v}}</span>
                                    <input type="text" name="attrs[items][]" v-show="false" v-model="attrItems[i]" />
                                </div>
                            </div>


                        </div>
                    </div>

                    <div class="row" v-show="productSkus.length">
                        <div class="col-md-12">
                            <table class="table table-bordered attr-table">
                                <thead>
                                <tr>
                                    <th v-for="(item, i) in attrGroups" :key="i">
                                        {{item}}
                                        <input type="text" name="attrs[group][]" v-show="false" v-model="item" />
                                    </th>
                                    <th>市场价</th>
                                    <th>销售价</th>
                                    <th>库存</th>
                                    <th>图片</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr v-for="(item, i) in productSkus" :key="i" :class="skus[i] && skus[i].stock <= 0 ? 'disabled' : ''">
                                    <td v-for="(v, j) in item" :key="j">{{v}}</td>
                                    <td width="80"><input type="text" name="attrs[market_price][]" v-model="skus[i] && skus[i].market_price " class="input-sm form-control attr-market_price" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"></td>
                                    <td width="80"><input type="text" name="attrs[price][]" v-model="skus[i] && skus[i].price" class="input-sm form-control attr-price" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"></td>
                                    <td width="80"><input type="text" name="attrs[stock][]" v-model="skus[i] && skus[i].stock" class="input-sm form-control attr-stock" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"></td>
                                    <td width="80">
                                        <input type="hidden" name="attrs[image][]" v-model="skus[i] && skus[i].image" :id="'c-attr-image-' + i">
                                        <input type="hidden" name="attrs[id][]" v-model="skus[i] && skus[i].id">
                                        <div class="sku-img" @click="upimage(i)">
                                            <img v-if="skus[i] && skus[i].image" :src="url+skus[i].image" :id="'img-attr-image-' + i">
                                            <span v-else>上传图片</span>
                                        </div>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                            <input type="text" v-show="false" name="attrs[sku]" v-model="productSkusStr">
                        </div>
                    </div>
                </div>
            </div>
            <style>
                [v-cloak] {
                    display: none;
                }
                ul, li {
                    list-style: none;
                    margin: 0;
                    padding: 0;
                }
                .no-padding {
                    padding: 0;
                }
                .pointer {
                    cursor: pointer;
                }
                .color-disabled {
                    color: #999;;
                }
                .input-group-addon {
                    padding: 6px 4px;
                }
                .tag {
                    padding: 2px 10px;
                    background-color: #ecf5ff;
                    color: #409eff;
                    border-radius: 4px;
                    border: 1px solid #d9ecff;
                    margin: 0 4px;
                }
                .panel header {
                    position: relative;
                }
                .panel header .header-input {
                    position: absolute;
                    right: 0;
                    top: 50%;
                    -webkit-transform: translateY(-50%);
                    -webkit-transform: translateY(-50%);
                    -moz-transform: translateY(-50%);
                    -ms-transform: translateY(-50%);
                    transform: translateY(-50%);
                }
                .panel-default>.panel-heading {
                    color: #333;
                    background-color: #f7fafa;
                    border-color: #eaeef1;
                }
            </style>
        </div>
    </div>

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script src="__CDN__/assets/js/jquery-1.11.0.js"></script>
<script type="text/javascript">
    $(".type_type").click(function(){
        var radio=   $('.type_type:checked').val();
        console.log(radio)
        if (radio==0){
            $(".is_ship").attr("style","display:none;");//隐藏div
            $(".is_ship").attr("style","display:none;");//隐藏div
        }else {
            $(".is_ship").attr("style","display:block;");//显示div
            $(".is_ship").attr("style","display:block;");//显示div
        }


    })
</script>